var t = require("../../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Component({
    properties: {
        params: {
            type: null
        },
        index: {
            type: null
        },
        data: {
            type: null
        },
        designer: {
            type: null
        },
        sessionurl: {
            type: null
        },
        Identification: {
            type: null
        },
        grouid: {
            type: null
        },
        total: {
            type: null
        },
        bottomShow: {
            type: null
        },
        isBottomnum: {
            type: null
        }
    },
    data: {
        language: "",
        showMore: !0,
        page: 1,
        total_page: 0,
        isLoadMore: !0
    },
    lifetimes: {
        attached: function() {
            var a = wx.getStorageSync("langIndex");
            this.setData({
                language: a.en
            }), this.triggerEvent("isLoadMorebtn", this.data.isLoadMore);
            for (var e = new Date().getTime(), i = 0; i < this.data.data.length; i++) {
                var o, s = this.data.data[i].start_time, n = new Date(s).getTime();
                this.setData((t(o = {}, "data[" + i + "].day", "00"), t(o, "data[" + i + "].hou", "00"), 
                t(o, "data[" + i + "].min", "00"), t(o, "data[" + i + "].sec", "00"), o)), e > n ? (this._countDown(i, this.data.data[i].end_time), 
                this.setData(t({}, "data[" + i + "].begShow", !0))) : (this._countDown(i, this.data.data[i].start_time), 
                this.setData(t({}, "data[" + i + "].begShow", !1)));
            }
        },
        moved: function() {},
        detached: function() {}
    },
    attached: function() {},
    ready: function() {},
    pageLifetimes: {
        show: function() {},
        hide: function() {},
        resize: function() {}
    },
    methods: {
        getMoreData: function() {
            var t = this;
            if (!(t.data.page >= t.data.total_page)) {
                t.setData({
                    page: t.data.page + 1
                });
                var e = a.getNetAddresss("home-page.get-page-goods");
                e += "&page=" + t.data.page, e += "&group_id=" + t.data.grouid, a._getNetWork({
                    url: e,
                    success: function(a) {
                        var e = a.data;
                        if (1 == e.result) {
                            var i = t.data.data;
                            t.setData({
                                data: i.concat(e.data.data)
                            }), t.data.page >= t.data.total_page && (t.setData({
                                isLoadMore: !1
                            }), t.triggerEvent("isLoadMorebtn", t.data.isLoadMore));
                        } else t.setData({
                            page: t.data.page - 1,
                            isLoadMore: !1
                        }), t.triggerEvent("isLoadMorebtn", t.data.isLoadMore);
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        },
        showTime: function(t) {
            return new Date().getSeconds >= new Date(t).getSeconds;
        },
        _countDown: function(a, e) {
            var i, o = new Date().getTime(), s = new Date(e).getTime();
            if (s - o > 0) {
                var n, d = (s - o) / 1e3, r = parseInt(d / 86400), g = parseInt(d % 86400 / 3600), u = parseInt(d % 86400 % 3600 / 60), h = parseInt(d % 86400 % 3600 % 60);
                this.setData((t(n = {}, "data[" + a + "].day", this._timeFormat(r)), t(n, "data[" + a + "].hou", this._timeFormat(g)), 
                t(n, "data[" + a + "].min", this._timeFormat(u)), t(n, "data[" + a + "].sec", this._timeFormat(h)), 
                n));
            } else {
                var l;
                this.setData((t(l = {}, "data[" + a + "].day", "00"), t(l, "data[" + a + "].hou", "00"), 
                t(l, "data[" + a + "].min", "00"), t(l, "data[" + a + "].sec", "00"), l));
            }
            s - o < 0 ? this.setData((t(i = {}, "data[" + a + "].day", "00"), t(i, "data[" + a + "].hou", "00"), 
            t(i, "data[" + a + "].min", "00"), t(i, "data[" + a + "].sec", "00"), i)) : setTimeout(this._countDown.bind(this, a, e), 1e3);
        },
        _timeFormat: function(t) {
            return t < 10 ? "0" + t : t;
        },
        buy: function(t) {
            var a = t.currentTarget.dataset.item;
            wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + a.goodid
            });
        }
    },
    observers: {
        isBottomnum: function(t) {
            console.log(t), this.getMoreData();
        },
        params: function() {
            this.setData({
                showMore: !0,
                page: 1,
                total_page: 0,
                isLoadMore: !0
            }), this.triggerEvent("isLoadMorebtn", this.data.isLoadMore), this.setData({
                total_page: Math.ceil(this.data.total / 12)
            }), this.data.page >= this.data.total_page && (this.setData({
                isLoadMore: !1
            }), this.triggerEvent("isLoadMorebtn", this.data.isLoadMore));
        }
    }
});